package com.dc.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.CreationTimestamp;

import javax.persistence.*;
import java.util.Date;

/**
 *  机电管子焊接  单船工序
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "t_workflow_machine_pipe")
public class WorkflowMachinePipeEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "submit_time")
    @JsonFormat(pattern = "yyyy-MM-dd")
    // 生成
    private Date submitTime = new Date();        // 填写日期

    @Transient
    private Long shipRepairId;      // 维修记录 外键id

    @Transient
    private String shipName;        // 船体名称

    @Transient
    private String reporter;        // 填报人

    @Column(name = "room", length = 50)     // 车间
    private String room;

    /////////////////////////////////////////////////////////////////////////////////////

    @Column(name = "device", length = 50)
    // 填写
    private String device;          // 部件

    @Column(name = "diam")
    // 填写
    private Double diam;            // 直径(mm)

    @Column(name = "zg_num")
    // 填写
    private Integer zgNum;          // 直管数量

    @Column(name = "wg_num")
    // 填写
    private Integer wgNum;          // 弯管数量

    @Column(name = "fl_num")
    // 填写
    private Integer flNum;          // 法兰数量

    @Column(name = "tg_num")
    // 填写
    private Integer tgNum;          // 套管数量

    @Transient
    private Double flLength;        // 法兰长度     // diam * flNum * pi

    @Transient
    private Double wgLength;        // 弯管长度     // diam * ( zgNum + wgNum + tgNum) * pi

    @Transient
    private Double wghfLength;        // 弯管焊缝长度     // wgLength / 1000

    @Transient
    private Double wgPowerByUnit;     // 弯管单位耗电量标定值

    @Transient
    private Double wgPower;           // 弯管耗电量   wgPowerByUnit * wghfLength

    @Transient
    private Double flhfLength;        // 法兰焊缝长度     // flLength / 1000

    @Transient
    private Double flPowerByUnit;     // 法兰单位耗电量标定值

    @Transient
    private Double flPower;           // 法兰耗电量  flPowerByUnit * flhfLength

    @Column(name = "create_time")
    @CreationTimestamp
    private Date createTime;

    @JsonIgnore
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "ship_repair_id", columnDefinition = "bigint unsigned NOT NULL")
    private ShipRepairEntity shipRepairEntity;
}
